package corp.edu.amadeus.core.bluetooth.inquiry;

import org.apache.log4j.Logger;
import org.junit.Assert;
import corp.edu.amadeus.core.bluetooth.management.DeviceManager;

public class InquiryThread extends Thread {

	private DeviceManager deviceManager = null;
	private static Logger log = Logger.getLogger(InquiryThread.class);

	public InquiryThread() {
		this.deviceManager = DeviceManager.getInstance();
	}

	public void run() {
		if(this.deviceManager.isInquiring()) {
			log.debug("++ Busqueda en curso ..., se cancela el lanzamiento.");
			return;
		}
		boolean started = false;
		started = this.deviceManager.startInquiry();
		Assert.assertTrue("La busqueda no se ha podido iniciar." ,
				started);
		/*while (true) {
			started = this.deviceManager.startInquiry();
			Assert.assertTrue("La busqueda no se ha podido iniciar." ,
					started);
			while (this.deviceManager.isInquiring()) {
				try {
					Thread.sleep(1000);
				} catch (Exception e) {
				}
			}
			break;
		}*/
    }

}